package map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo02 {
    public static void main(String[] args) {
        Map<String ,Integer> map = new HashMap<>();
        map.put("数学",98);
        map.put("英语",97);
        map.put("物理",96);
        map.put("化学",99);

        Set<String > keys = map.keySet();
        for (String key:keys) {
            System.out.println(key);
        }

        Collection<Integer> values = map.values();
        for (Integer value:values) {
            System.out.println(value);
        }

        Set<Map.Entry<String ,Integer>> entries = map.entrySet();
        for (Map.Entry<String ,Integer> entry:entries) {
            System.out.println(entry.getKey()+"-->"+entry.getValue());
        }

        map.forEach((k,v)->{
            System.out.println(k+"-->"+v);
        });



    }

}
